package com.jrx.anytxn.accounting.job.consolidationcheck.step;

import com.jrx.anytxn.accounting.mapper.ext.ExtVoucherExcpReportMapper;
import com.jrx.anytxn.param.entity.PrOrganizationTable;
import com.jrx.anytxn.param.service.system.IOrganizationTableService;
import com.jrx.anytxn.transaction.constant.TransBizConstant;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 *
 * @author : yf
 * 2019/12/18
 */
@Service
public class ConsolidationCheckListener implements JobExecutionListener {

    @Resource
    private ExtVoucherExcpReportMapper extVoucherExcpReportMapper;

    @Autowired
    private IOrganizationTableService organizationTableService;

    @Override
    public void beforeJob(JobExecution jobExecution) {
        PrOrganizationTable org = organizationTableService.findByOrgIdForBatch(TransBizConstant.DEFAULT_ORG_ID);
        Date businessDate = org.getToday();
        extVoucherExcpReportMapper.deleteByDate(businessDate);
    }

    @Override
    public void afterJob(JobExecution jobExecution) {

    }
}
